<!DOCTYPE html>
{% load static %}
<html lang="zh-hans">
<head>
    <meta charset="UTF-8">
    <title>文章管理 - 我的博客</title>
    <link rel="stylesheet" href="{% static 'users/bulma.css' %}">
    <style>
        .management-container {
            max-width: 1200px;
            margin: 2rem auto;
            padding: 0 1rem;
        }
        .management-table {
            box-shadow: 0 2px 6px rgba(0,0,0,0.1);
            border-radius: 8px;
            overflow: hidden;
        }
        .operation-buttons {
            min-width: 120px;
        }
    </style>
</head>
<body>
    <!-- 导航栏 -->
    <nav class="navbar is-primary">
        <div class="container">
            <div class="navbar-brand">
                <a class="navbar-item" href="/">
                    <strong>我的博客</strong>
                </a>
            </div>
            <div class="navbar-menu">
                <div class="navbar-end">
                    <div class="navbar-item">
                        <a href="{% url 'users:user_info' %}" class="button is-light">
                            返回个人中心
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </nav>

    <!-- 主内容 -->
    <div class="management-container">
        <div class="box is-shadowless">
            <h2 class="title is-4 mb-5">文章管理</h2>

            <div class="management-table">
                <table class="table is-fullwidth is-hoverable">
                    <thead>
                        <tr>
                            <th>标题</th>
                            <th>分类</th>
                            <th>发布时间</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for post in posts %}
                        <tr>
                            <td>{{ post.title|truncatechars:30 }}</td>
                            <td>{{ post.category.name|default:"未分类" }}</td>
                            <td>{{ post.add_date|date:"Y-m-d" }}</td>
                            <td class="operation-buttons">
                                <a href="{% url 'blog:delete_post' post.id %}"
                                   class="button is-danger is-small">
                                    <i class="fas fa-trash"></i> 删除
                                </a>
                            </td>
                        </tr>
                        {% empty %}
                        <tr>
                            <td colspan="4" class="has-text-centered">暂无文章</td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>

    <!-- 页脚 -->
    <footer class="footer">
        <div class="content has-text-centered">
            <p>© 2025 我的博客 版权所有</p>
        </div>
    </footer>
</body>
</html>